package in.muton.edushare.jobs;

import in.muton.edushare.academics.alerts.CourseCodeAlert;
import in.muton.edushare.wicket.models.CayenneModel;

import java.util.List;

import org.apache.cayenne.access.DataContext;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.edushare.common.dao.CoursesDAO;
import com.edushare.common.dao.UniversitiesDAO;
import com.edushare.common.orm.CayenneORMInterface;
import com.edushare.common.vo.Courses;
import com.edushare.common.vo.Universities;

public class CourseInfoReminderJob implements EduShareJob {
	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		CayenneORMInterface ormIntf = new CayenneORMInterface();
		ormIntf.setDataContext(DataContext.createDataContext());

		List<Universities> univList = new UniversitiesDAO(ormIntf)
				.getAllUniversities();
		for (Universities univ : univList) {
			List<Courses> courseList = new CoursesDAO(ormIntf)
					.getUnivCourses(univ);
			for (Courses c : courseList) {
				new CourseCodeAlert(new CayenneModel<Courses>(c), ormIntf)
						.sendMessage();
			}
		}
	}
}
